<template>
  <div class="medical">
    <div class="header-top">
      <span>随访记录</span>
      <div @click="onJumpFollowUp">跳转到随访 ></div>
    </div>
    <el-divider></el-divider>
    <el-table :data="dataList" border>
      <el-table-column type="month" label="名称" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.month }}月</span>
        </template>
      </el-table-column>
      <el-table-column type="followStatus" label="状态" align="center">
        <template slot-scope="scope">
          <span>{{ getName(scope.row.followStatus) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="actualEvaluationDate"
        label="年月日"
        align="center"
      />
      <el-table-column prop="followUpDept" label="随访科室" align="center" />
      <el-table-column prop="followUpDoctor" label="随访医生" align="center" />
    </el-table>
  </div>
</template>

<script>
import { getCpFollowUpTaskList } from "@/api/follow-up/chest-pain";
export default {
  props: ["checkrowdata"], // 由主页面(父组件) 接收来的, 选择项的数据
  data() {
    return {
      dataList: [],
    };
  },
  created() {
    this.getDataList();
  },
  methods: {
    async getDataList() {
      const result = await getCpFollowUpTaskList({
        dispatchId: this.checkrowdata.dispatchId,
      });
      if (!result) return;
      Object.keys(result.data).forEach((key) => {
        this.dataList.push({
          ...result.data[key],
        });
      });
    },
    onJumpFollowUp() {
      this.$router.push({
        path: "/follow-up-list/chest-pain",
        query: {
          dispatchId: this.checkrowdata.dispatchId,
        },
      });
    },
    getName(value) {
      switch (value) {
        case 0:
          return "未开始";
          break;
        case 1:
          return "随访中";
          break;
        case 2:
          return "已上报";
          break;
        case 3:
          return "已过期";
          break;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.medical {
  padding: 20px;
  .header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    span {
      font-weight: 700;
    }
    div {
      cursor: pointer;
    }
  }
}
</style>
